[EDR Workflows] Speed up MS Defender runscript Jest tests by mocking p-retry#268311
Merged
szwarckonrad merged 4 commits intoMay 11, 2026
Merged
Conversation
|
Pinging @elastic/security-defend-workflows (Team:Defend Workflows) |
Contributor
💚 Build Succeeded
Metrics [docs]
History
|
clintandrewhall
pushed a commit
that referenced
this pull request
May 12, 2026
…p-retry (#268311) ## Summary Two tests in `ms_defender_endpoint_actions_client.test.ts` (`should throw error when GET_ACTIONS returns no action details after retry` and `should throw error when GET_ACTIONS call fails`) intermittently exceeded Jest's 5s default. Both exercise the production retry path in `fetchAndValidateRunscriptActionDetails`, which uses `pRetry` with `retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5` — ~4s of real-time sleep before the outer catch returns `Action details not found`. This PR mocks `p-retry` at the file level (delegating to the real implementation by default), and short-circuits it with `mockImplementationOnce(async (fn) => fn(1))` in the two slow tests. Mirrors the existing pattern in `license_watch.test.ts` and `reference_data/helpers.test.ts`. The two `// TODO: Fix this slow test` markers are removed.
patrykkopycinski
pushed a commit
to patrykkopycinski/kibana
that referenced
this pull request
May 13, 2026
…p-retry (elastic#268311) ## Summary Two tests in `ms_defender_endpoint_actions_client.test.ts` (`should throw error when GET_ACTIONS returns no action details after retry` and `should throw error when GET_ACTIONS call fails`) intermittently exceeded Jest's 5s default. Both exercise the production retry path in `fetchAndValidateRunscriptActionDetails`, which uses `pRetry` with `retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5` — ~4s of real-time sleep before the outer catch returns `Action details not found`. This PR mocks `p-retry` at the file level (delegating to the real implementation by default), and short-circuits it with `mockImplementationOnce(async (fn) => fn(1))` in the two slow tests. Mirrors the existing pattern in `license_watch.test.ts` and `reference_data/helpers.test.ts`. The two `// TODO: Fix this slow test` markers are removed.
jcger
pushed a commit
that referenced
this pull request
May 26, 2026
…p-retry (#268311) ## Summary Two tests in `ms_defender_endpoint_actions_client.test.ts` (`should throw error when GET_ACTIONS returns no action details after retry` and `should throw error when GET_ACTIONS call fails`) intermittently exceeded Jest's 5s default. Both exercise the production retry path in `fetchAndValidateRunscriptActionDetails`, which uses `pRetry` with `retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5` — ~4s of real-time sleep before the outer catch returns `Action details not found`. This PR mocks `p-retry` at the file level (delegating to the real implementation by default), and short-circuits it with `mockImplementationOnce(async (fn) => fn(1))` in the two slow tests. Mirrors the existing pattern in `license_watch.test.ts` and `reference_data/helpers.test.ts`. The two `// TODO: Fix this slow test` markers are removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two tests in
ms_defender_endpoint_actions_client.test.ts(should throw error when GET_ACTIONS returns no action details after retryandshould throw error when GET_ACTIONS call fails) intermittently exceeded Jest's 5s default. Both exercise the production retry path infetchAndValidateRunscriptActionDetails, which usespRetrywithretries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5— ~4s of real-time sleep before the outer catch returnsAction details not found.This PR mocks
p-retryat the file level (delegating to the real implementation by default), and short-circuits it withmockImplementationOnce(async (fn) => fn(1))in the two slow tests. Mirrors the existing pattern inlicense_watch.test.tsandreference_data/helpers.test.ts. The two// TODO: Fix this slow testmarkers are removed.